<!-- Panels Start -->
<script type="text/javascript" charset="utf-8">
    $(document).ready(function() {
        $("a[rel^='prettyPhoto']").prettyPhoto();
    });
</script>    
<?
    $imageWidth = "100";
    $imageHeight = "80";
?>
<div class="mws-panel grid_8">
    <div class="mws-panel-header">
        <span class="mws-i-24 i-table-1"><?= $this->pageHeading ?></span>
    </div>

    <div class="mws-panel-body">
        <div class="mws-panel-toolbar top clearfix ">
            <ul>
                <li><a class="mws-ic-16 ic-accept" href="<?= APPLICATION_URL_ADMIN ?>photo/homepageimageadd" title="Add">Add</a></li>
                <li><a class="mws-ic-16 ic-cross" href="javascript:void(0)" title="Delete" onclick="deleteitem()">Delete</a></li>
            </ul>
        </div>
        <!--<table class="mws-table">-->
        <table class="mws-datatable-fn-draggable-home  mws-table">
            <thead>
                <tr>
                    <th width="5%">S.No</th>
                    <th width="5%"><input type="checkbox" name="deletebcchk" id="deletebcchk" onclick="return checkall(this)" /></th>
                    <th width="20%">Property Image</th>
                    <th width="20%">Image Caption</th>
                    <th width="5%">Status</th>
                    <th width="5%">Edit</th>
                </tr>
            </thead>
            <tbody>
                <?
                    $i = 0;
                    if (count($this->ResData) > 0)
                    {
                        echo "<ul id='mws-gallery' class='clearfix'>";
                        foreach ($this->ResData as $row)
                        {
                            $start++;
                            $i++;
                            if ($row['status'] == 1)
                            {
                                $image = 'tick.png';
                            }
                            if ($row['status'] == 0)
                            {
                                $image = 'cross.png';
                            }
                            ?>
                            <tr class="gradeX" id = "<?= $row['id'] ?>">
                                <td><?= $i; ?></td>
                                <td>
                                    <input name='check<?= $i; ?>' id='check<?= $i; ?>' value='<?= $row['id']; ?>' 
                                           onchange='return check_check("bcdel", "deletebcchk")' type='checkbox'>
                                </td>
                                <td>
                                    <img src="<?= APPLICATION_URL ?>image.php?image=uploads/<?= $row['img_name']; ?>&height=<?= $imageHeight ?>&width=<?= $imageWidth ?>" alt="slider images" title="<?= $row['image_title']; ?>" />
                                </td>
                                <td><?= $row['image_text']; ?></td>            
                                <td>
                                    <a id='<?= $start; ?>' onclick='changestatus("<?= $row['id']; ?>", "<?= $row['status']; ?>")' href="javascript:void(0)" >
                                        <img src="<?= APPLICATION_URL_ADMIN ?>css/icons/32/<?= $image; ?>"   border='0' height="16" width="16" title='Change Status' alt='Change Status'>
                                    </a>	
                                </td>
                                <td>
                                    <a href="<?= APPLICATION_URL_ADMIN; ?>photo/homepageimageedit/id/<?= $row['id']; ?>" style="text-decoration:none;">
                                        <img src="<?= APPLICATION_URL_ADMIN; ?>css/icons/32/application_form_edit.png" height="16" width="16"   border='0' title='Edit' alt='Edit'>
                                    </a>
                                </td>
                            </tr>
                            <?
                        }
                        echo "</ul>";
                        ?>

                        <?
                    }
                    else
                    {
                        echo "<div align='center'>No data available in table</div>";
                    }
                ?>	
            </tbody>
        </table>
    </div>    	
</div>

<!-- Panels End -->

<script>
    function deleteitem()
    {
        var r = "";
        var s = "";
        var selected = false;
        for (var i = 1; document.getElementById('check' + i); i++) {
            if (document.getElementById('check' + i).checked == true) {
                r += document.getElementById('check' + i).value + "|";
                selected = true;
            }
        }

        r += '0';
        if (selected) {
            var confirmation = confirm("Are you sure want to delete ?");
            if (confirmation != true) {
                return false;
            }

            $.ajax({url: "<?= APPLICATION_URL_ADMIN . "photo/homepageimagedelete/Id" ?>",
                type: "POST",
                data: ({Id: r}),
                success: function(data) {
                    window.location.href = window.location.href;
                }});
        } else {
            alert('Please choose a record to delete.');
        }
    }

    function changestatus(Id, Status)
    {
        $.ajax({
            type: "POST",
            url: "<?= APPLICATION_URL_ADMIN ?>slides/changestatus/lppty_type/0",
            data: ({Id: Id, Status: Status}),
            cache: false,
            success: function(data) {
                window.location.href = window.location.href;
            }
        });
    }
    function checkall(thisid)
    {
        for (var i = 1; document.getElementById('check' + i); i++) {
            if (document.getElementById(thisid.id).checked == true) {
                document.getElementById('check' + i).checked = true;
            }
            if (document.getElementById(thisid.id).checked == false) {
                document.getElementById('check' + i).checked = false;
            }
        }
    }
</script>